<?php

$__FILEPATH__ = dirname(__FILE__)."/";

require_once($__FILEPATH__."../func_common.php");
require_once($__FILEPATH__."../class_def.php");
require_once($__FILEPATH__."../conf/info.php");
require_once("$fckeditorpath");

CheckAdminAndInitHeader();

function GetTitle($id)
{
	$title = $GLOBALS["namestr_team"];
	switch($id)
	{
		case 1: $title = $GLOBALS["namestr_team"]; break;
		case 2: $title = $GLOBALS["namestr_icpc"]; break;
		case 3: $title = $GLOBALS["namestr_teacher"]; break;
		case 4: $title = $GLOBALS["namestr_book"]; break;
	}

	return $title;
}


$id = 1;
if (isset($_POST["submit"]) && isset($_POST["id"]))
{
	$id = intval($_POST["id"]);
	SetFileContent($__FILEPATH__.GetFileNameById($id), $_POST["content"]);
}
else if (isset($_GET["id"])) 
{
	$id = intval($_GET["id"]);
}

$filepath = $__FILEPATH__.GetFileNameById($id);
$title = GetTitle($id);
$content = GetFileContent($filepath);
$time = GetSysTime();
if (file_exists($filepath))
	$time = GetSysTime(filemtime($filepath));

?>